import { wallet as Wallet } from "../../utils/wallet"
import { Card } from "../../model/Card"

Page({
  data: {
    userinfo: {},
    login:"",
    verifyman:"",
    distributor:"",
    envVersion:'',
    money:'00.00',
    cardArrayLength:0
  },

  //生命周期函数--监听页面加载
  onLoad:function(){
    this.setData({
      verifyman: parseInt(wx.getStorageSync('verifyman')),
      distributor: parseInt(wx.getStorageSync('distributor')),
      envVersion:wx.getAccountInfoSync(),
    })
    
  },

  //生命周期函数--监听页面显示
  onShow: async function () {
    const userinfo = wx.getStorageSync('userinfo');
    let result = await Card.get_card_list_by_uid();
    this.setData({
      login: wx.getStorageSync('register'),
      userinfo,
      cardArrayLength:result.data.length
    });

    //获取 会员钱包余额的方法
    let wallet = await Wallet.walletMoney()
    this.setData({
      money: wallet.balance
    })

  },

})
